home *** CD-ROM | disk | FTP | other *** search
/ Die Speccy' 97 / Die Speccy' 97.iso / amiga_system / the_aminet / dev / src / spr12.lha / patch2.asm < prev    next >
Assembly Source File  |  1995-10-31  |  3KB  |  124 lines

  1.          SECTION  text,CODE
  2.          ;
  3.          ;        Benefits:
  4.          ;        1)  Unlike patch1.asm, this method can call other routines
  5.          ;            at will.  Unfortunately, it use slightly more CPU for
  6.          ;            removal management.
  7.          ;
  8.          ;        Restrictions:
  9.          ;        1)  None (that I can think of B-))
  10.          ;
  11.          ;
  12.          ;        Export symbols
  13.          ;
  14.          XDEF     _patchStart
  15.          XDEF     _patchEnd
  16.          XDEF     _codeStart
  17.          XDEF     _codeEnd
  18.          XDEF     _UCount_Offset
  19.          XDEF     _SigBit_Offset
  20.          XDEF     _Task_Offset
  21.          XDEF     _RtsNop_Offset
  22.          ;
  23.          ;        Import symbols
  24.          ;
  25.          XREF     _AbsExecBase
  26.          XREF     _LVODisable
  27.          XREF     _LVOEnable
  28.          XREF     _LVOSignal
  29.          ;
  30.          ;        Here begins the patch.
  31.          ;
  32. _patchStart:
  33.          ;
  34.          ;        Here begins the patch code.
  35.          ;
  36. _codeStart:
  37.          ;
  38.          ;        Increment the nesting count.
  39.          ;
  40.          move.l   a0,-(sp)
  41.          lea.l    NCOUNT(pc),a0
  42.          addq.l   #1,(a0)
  43.          move.l   (sp)+,a0
  44.          ;
  45.          ;        Do whatever the patch needs to do...
  46.          ;
  47.          move.l   #10,d0
  48.          ;
  49.          ;        Decrement the nesting count.
  50.          ;
  51.          move.l   a0,-(sp)
  52.          lea.l    NCOUNT(pc),a0
  53.          subq.l   #1,(a0)
  54.          move.l   (sp)+,a0
  55.          ;
  56.          ;        When the patch is to be removed, we change the following
  57.          ;        RTS to a NOP instruction.  This way we don't have any
  58.          ;        overhead in the patch.
  59.          ;
  60. RTSNOP   rts
  61.          ;        Here ends the patch code.
  62.          ;
  63.          ;        Here begins the removal code.
  64.          ;
  65.          ;        Preserve registers.
  66.          ;
  67.          movem.l  d0-d1/a0-a1,-(sp)
  68.          ;
  69.          ;        We decrement the UCOUNT field until it reaches zero.
  70.          ;
  71.          lea.l    UCOUNT(pc),a0
  72.          subq.l   #1,(a0)
  73.          bne.b    10$
  74.          ;
  75.          ;        The UCOUNT field has reached zero so notify remover that it's
  76.          ;        okay to free storage.  Remember that we are still Disabled()
  77.          ;        so the remover can't free our storage yet.
  78.          ;
  79.          move.l   SIGNAL(pc),d0
  80.          move.l   TASK(pc),a1
  81.          move.l   a6,-(sp)
  82.          move.l   _AbsExecBase.W,a6
  83.          jsr      _LVOSignal(a6)
  84.          move.l   (sp)+,a6
  85.          ;
  86.          ;        Restore registers
  87.          ;
  88. 10$      movem.l  (sp)+,d0-d1/a0-a1
  89.          ;
  90.          ;        Return to caller
  91.          ;
  92.          rts
  93. _codeEnd:
  94.          ;
  95.          ;        Here ends the removal code.
  96.          ;
  97.          ;
  98.          ;        Here begins the removal variables.
  99.          ;
  100. NCOUNT   dc.l     0
  101. UCOUNT   dc.l     0
  102. SIGNAL   dc.l     0
  103. TASK     dc.l     0
  104.          ;
  105.          ;        Here ends the patch.
  106.          ;
  107. _patchEnd:
  108.          ;
  109.          ;        Here begins some convenience fields.  There are not part of
  110.          ;        the patch.
  111.          ;
  112. _UCount_Offset:
  113.          DC.L     UCOUNT-_patchStart
  114. _SigBit_Offset:
  115.          DC.L     SIGNAL-_patchStart
  116. _Task_Offset:
  117.          DC.L     TASK-_patchStart
  118. _RtsNop_Offset:
  119.          DC.L     RTSNOP-_patchStart
  120.          ;
  121.          ;        The End
  122.          ;
  123.          END
  124.